home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
asmutil
/
asm_n_z.zip
/
XONE23.ASM
< prev
next >
Wrap
Assembly Source File
|
1987-10-12
|
16KB
|
753 lines
page 75,132
title XONE - Make one ARC file from a member file
; usage:
; XONE inputname[.ARC] [filename] [outputname] [/R]
;
; remarks:
; The 'inputname' is required. It defines the ARC archive
; file which contains the member files that you want to extract.
; The extension defaults to .ARC.
;
; The 'filename' is optional. If omitted, all files in the
; archive are extracted. If supplied, only that file in the
; archive that matches the 'filename' is extracted.
; Each extracted file is created in the ARC format using the
; the original file name.
;
; The 'outputname' is optional. If supplied, it defines the name
; to be used for the extracted file. To use this operand, you must
; also supply the 'filename' operand to extract a single file.
;
; restrictions:
; XONE was written by Vernon Buerg and is for use without
; restrictions. Please try to distribute this program as-is,
; and without modification.
.xlist
print macro name ; display a field
mov dx,offset name
call prints
endm
printl macro text,ctl ; display a literal
local txt,nxt
mov dx,offset txt
call prints
jmp nxt
txt db cr,lf,&text
ifnb < ctl>
db cr,lf,stopper
else
db stopper
endif
nxt equ $
endm
.sall
.list
header struc ; archive header
mbrcode db 0 ; compression code
mbrname db 13 dup (0) ; file name
mbrsize dw 0,0 ; file size in archive
mbrdate dw 0 ; creation date
mbrtime dw 0 ; creation time
mbrcrc dw 0 ; cyclic redunancy check
mbrlen dw 0,0 ; true file size, bytes
header ends
cseg segment public para 'CODE'
assume cs:cseg,ds:cseg,es:cseg
org 100h
xone proc far
jmp start ; do our thing
version db cr,' ',cr,lf ; overlay jmp above
db ' XONE Make ARC file from member file(s) ',cr,lf
db ' ---- Version 2.3 - by Vern Buerg',cr,lf,stopper
usage db cr,lf,' usage: XONE archive[.ARC] [filespec] [output] [/R]'
db cr,lf,eof
db stopper ; 2.3, oops
page
;
; return with error
error: mov ax,cs ; insure seg regs
mov ds,ax ; for proper exit
mov sp,cs:stkptr
mov errlvl,1 ; set bad return code
; mov dl,7 ; send bel char
; mov ah,2 ; to standard output
; int 21h
; set DOS error level and exit
exit: mov sp,cs:stkptr ; just in case
mov al,errlvl ; return code
mov ah,4ch ; exit function
int 21h
subttl '--- constants, equates and work areas'
page
cr equ 13
lf equ 10
bel equ 7
tab equ 9
eof equ 26
stopper equ 255 ; end of display line indicator
arcmark equ 26 ; special archive marker
xoneer equ 9 ; highest compression code used ;2.2
stkptr dw 0 ; stack pointer upon entry
errlvl db 0 ; dos error level returned
psp dw 0 ; addr of psp
prompt db ' already exists, re-use it? (y/N) ',stopper
answer db 'n',cr,stopper
found db 0 ; indicates if found a member
reuse db 0 ; non-zero means overwrite existing file(s)
notfnd db cr,' Member file not found - '
member db 13 dup (0),0 ; selected member name
db cr,lf,stopper
archdl dw 0 ; ARC file handle
arcname db 76 dup (stopper)
outmsg db ' -> ' ; tells you what is being used
outname db 76 dup (0) ; output file name
; i/o control variables
inbufsz equ 18*1024 ; size of input buffer
inadr dw offset inbuf ; offset to input buffer
inptr dw offset inbuf ; offset to current byte
insize dw inbufsz ; size of input buffer
inlen dw 0 ; bytes left in buffer
incurh dw 0 ; current file offset
incurl dw 0 ; low word
outbufsz equ 18*1024 ; size of output buffer
outlen dw outbufsz ; bytes empty in output buffer
outadr dw offset outbuf ; offset to output buffer
outptr dw offset outbuf ; spot for next output char
outsize dw outbufsz ; size of output buffer
outhdl dw 0 ; output file handle
vline db cr,lf
vstyle db ' ' ; compression method
db 'ed: '
vname db 12 dup (0),0
db stopper,0
styles db ' sav' ; 1 = old, no compression
db ' Sav' ; 2 = new, no compression
db ' Pack' ; 3 = dle for repeat chars
db ' Squeez' ; 4 = huffman encoding
db ' crunch' ; 5 = lz, no crc
db ' crunch' ; 6 = lz with crc
db ' SEA' ; 7 = internal SEA use
db ' Crunch' ; 8 = new lz with crc
db ' squash' ; 9 = pk squashing
wtg dw 0 ; index into where table
where dw offset copy1 ; offset to routines for each type
dw offset copy2
dw offset unpack3
dw offset unsqueez4
dw offset uncrunch5
dw offset uncrunch6
dw offset uncrunch7
dw offset uncrunch8
dw offset unsquash9
subttl '--- mainline processing'
page
;
; gather command line operands
start:
mov stkptr,sp ; save stack ptr
mov ax,cs
mov ds,ax ; set local data seg
mov cx,es
mov psp,cx ; save psp addr
mov es,ax
print version ; display program version
mov si,80h ; get command line operand
sub cx,cx
or cl,byte ptr [si] ; any operand?
jnz parm1
parm_error:
print usage ; no, gotta have the ARC name
jmp error
; pick off any trailing '/R' parameter
parm1: inc si ; point to operand
mov bx,si
add bx,cx ; point to end of command line
cmp word ptr -2[bx],'R/' ; is reuse specified?
je parm1r
cmp word ptr -2[bx],'r/'
jne parm2
parm1r: or reuse,1 ; indicate no checking
mov word ptr -2[bx],0d0dh ; stop command line here
sub cx,2 ; remove /R from command line
jle parm_error ; oops, something is missing
; get first operand - input archive file name
parm2: lodsb ; strip leading blanks
cmp al,' '
loope parm2
mov di,offset arcname
stosb
parm3: lodsb ; copy ARC filename
cmp al,cr ; end of name?
je parm4
cmp al,' ' ; delimiter?
je parm4
cmp al,tab ; delimiter?
je parm4
cmp al,',' ; delimiter?
je parm4
stosb
cmp al,'.' ; got extension now?
je parm5 ; yup, that's nice
loop parm3
parm4: mov ax,'A.' ; append default ext
stosw
mov ax,'CR'
stosw
jmp short parm6
; strip trailing blanks looking for second operand
parm5: lodsb ; next ext char
cmp al,cr ; end of it?
je parm6
cmp al,' ' ; delimiter?
je parm6
cmp al,tab ; another delimiter?
je parm6
stosb ; copy supplied extension
loop parm5
parm5a: dec di ; back up to end of ext
parm6: mov al,0 ; append asciiz stopper
stosb
; copy optional second (file selection) operand
or cx,cx ; another operand?
jz parm_done ; nope, extract all files
mov di,offset member
parm7: lodsb
cmp al,cr ; end of operand?
je parm20 ; yes, done
cmp al,' ' ; delimiter for third operand?
je parm10
cmp al,tab
je parm10
cmp al,'a' ; lower case?
jb parm8
sub al,32
parm8: stosb
loop parm7
parm9: mov ax,0ff00h ; append asciiz stopper
stosw
jmp short parm_done
; get third operand, if any, as output file name
parm10: sub cx,1 ; account for delimiter
jle parm_done
mov di,offset outname ; third operand is target filename
parm11: lodsb
cmp al,' ' ; strip leading blanks
loope parm11
cmp al,cr ; ending c/r?
je parm_done ; just trailing blanks, then
jcxz parm20
parm12: stosb ; blindly copy the rest
lodsb
cmp al,cr
loopne parm12
parm20: mov ax,0ff00h ; append stoppers
stosw
parm_done: ; hope we've got everything
call openarc ; access the archive file
jnc xonenext
ret
page
;
; process next archive header entry
xonenext:
call gethdr ; load next header
jnc xone2 ; get CF at end of file, etc
jmp exit ; all done
xone2: cmp archdr.mbrcode,0 ; archive eof?
jne xone2a ; nope, keep on truckin
printl ' ' ; blank line
call closarc ; close file
cmp member,0 ; selecting one file?
je xone_ok ; no, skip next
cmp found,0 ; and did we get it?
jne xone_ok
print notfnd
printl ' '
xone_ok:
jmp exit ; depart
xone2a:
cmp member,0 ; selecting one file?
je xonego ; no, skip next
mov si,offset member ; yes, compare names
mov di,offset archdr.mbrname
mov cx,13
xonesel:
lodsb
cmp